<?php
/***************************************************************************
 *   copyright : (C) 2009 Udrea Cristian
 *   site : http://code.google.com/p/testauction-php
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as 
 *   published by the Free Software Foundation; either version 2 of the
 *   License, or (at your option) any later version. Although none of the
 *   code may be sold. If you have been sold this script, get a refund.
 ***************************************************************************/
class Clock extends Element{
	public function __construct(){
		$this->setContents("<script type=\"text/javascript\">".
			"var clockLocalStartTime = new Date();".
			"var clockServerStartTime = new Date(".$this->getServerDateItems(time()).");".
			"function clockInit(){}</script>".
			"<script type=\"text/javascript\" src=\"scripts/clock.js\"></script>".
			"<script type=\"text/javascript\" src=\"scripts/functions.js\"></script>".
			"<script type=\"text/javascript\">clockUpdate();</script>");
	}
	public function toString(){
		return "<div id=\"clockTime\" style=\"font-weight: bold; float: right;\">Ora: ".$this->clockTimeString(time())."</div>";
	}
	private function getServerDateItems($inDate) {
		return date('Y,n,j,G,',$inDate).intval(date('i',$inDate)).','.intval(date('s',$inDate));
	}
	private function clockTimeString($inDate) {
		return date('g:i:s',$inDate).' ';
	}
}
$clock = new Clock();
?>
